<?php
namespace app\admin\controller;
use think\Db;
use lib\Curl;
class Cooperate extends Base{
    //广告图
    public function cooperate_banner(){
        if(request()->isGet()){
            $param = input('get.');
            $data=Db::name('cooperate_banner')->where('id',1)->find();
            $this->assign('data',$data);
            return $this->fetch();
        }elseif(request()->isPost()){
            $param = input('post.');
            $data['title']=$param['title'];
            $data['banner']=$param['banner'];
            $data['title_en']=$param['title_en'];
            $res= Db::name('cooperate_banner')->where(array('id'=>1))->update($data);
            if($res){
                return json(['code' => 200,'msg' => '更新成功']);
            }else{
                return json(['code' => 500,'msg' => '失败']);
            }
        }
    }
    public function cooperate_item(){
        if(request()->isGet()){
            $param = input('get.');
            $data=Db::name('cooperate')->where('id',1)->find();
            $this->assign('data',$data);
            return $this->fetch();
        }elseif(request()->isPost()){
            $param = input('post.');
            $data['title']=$param['title'];
            $data['title_l']=$param['title_l'];
            $data['subtitle_l']=$param['subtitle_l'];
            $data['detail']=html_entity_decode($param['detail']);
            $data['seo_keywords']=$param['seo_keywords'];
            $data['seo_description']=$param['seo_description'];
            $res= Db::name('cooperate')->where(array('id'=>1))->update($data);
            if($res){
                return json(['code' => 200,'msg' => '更新成功']);
            }else{
                return json(['code' => 500,'msg' => '失败']);
            }
        }
    }
    public function cooperate_process(){
        if(request()->isGet()){
            $param = input('get.');
            $data=Db::name('cooperate')->where('id',2)->find();
            $this->assign('data',$data);
            return $this->fetch();
        }elseif(request()->isPost()){
            $param = input('post.');
            $data['title']=$param['title'];
            $data['title_l']=$param['title_l'];
            $data['subtitle_l']=$param['subtitle_l'];
            $data['detail']=html_entity_decode($param['detail']);
            $data['seo_keywords']=$param['seo_keywords'];
            $data['seo_description']=$param['seo_description'];
            $res= Db::name('cooperate')->where(array('id'=>2))->update($data);
            if($res){
                return json(['code' => 200,'msg' => '更新成功']);
            }else{
                return json(['code' => 500,'msg' => '失败']);
            }
        }
    }
}